@extends('home.parent')
@section('title','基础设置')
@section('head_js')
@endsection
@section('head_css')
@endsection
@section('content')
<div class="content-wrapper">
<section class="content-header">
	<h1>
		基础设置
		<small></small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="{{URL('admin')}}"><i class="fa fa-dashboard"></i> 首页</a></li>
		<li class="active">基础设置</li>
	</ol>
</section>
<style>
.box-body div.testall{border:1px solid #d5d5d5;color:#717171;}
.box-body div.testall div label{padding: 6px 15px 0 0;text-align:right;margin:0;min-width  :160px;}
.box-body div.testall div input[type="text"],.box-body div.testall div select{display:inline-block;width:50%;min-width:100px;}
.box-body div.testall div button{margin-right:10px;}
.upimg{margin-left:160px;}
.upimg img{width:120px;height:120px;margin-top:-20px;}
.upimg input[type="file"]{display:none;}
.upimg span{margin:10px 0 10px 10px;}
.upimg span#remove,.upimg span#upload{display:none;}
.box-body div.testall div.col-md-6{min-width:360px;padding-top:20px;}
.box-body div.testall div.col-md-12{margin-left:160px;padding-top:20px;}
@media screen and (max-width: 480px) {
	.box-body div.testall div label{text-align:left;}
	.box-body div.testall div input[type="text"],.box-body div.testall div select{width:80%;}
	.upimg{margin:20px 0 0 0;}
	.box-body div.testall div.col-md-6{min-width:auto;}
	.box-body div.testall div.col-md-12{margin-left:0;}
}
</style>
<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box box-primary">
				<div class="box-body">
					<!--  star-->
					<div class="form-group col-md-12 testall" style="padding-top:20px;">
						<form class="" action="" method="">
						<div class="form-group col-md-6">
							<label>合伙人充值比例：</label>
							<input type="text" class="form-control" name="partner_discount" value="{{ isset($data['basics']['partner_discount'])?$data['basics']['partner_discount']:'' }}" placeholder="小于等于100的数值，最多一位小数" maxlength="5">
						</div>
						<div class="form-group col-md-6">
							<label>用户充值折扣：</label>
							<input type="text" class="form-control" name="vip_discount" value="{{ isset($data['basics']['vip_discount'])?$data['basics']['vip_discount']:'' }}" placeholder="小于10的数值，最多一位小数" maxlength="3">
						</div>
						<div class="form-group col-md-6">
							<label>合伙人最低充值金额：</label>
							<input type="text" class="form-control" name="partner_amount" value="{{ isset($data['basics']['partner_amount'])?$data['basics']['partner_amount']:'' }}" placeholder="请输入合伙人最低充值金额" maxlength="10">
						</div>
						<div class="form-group col-md-6">
							<label>用户最低充值金额：</label>
							<input type="text" class="form-control" name="vip_amount" value="{{ isset($data['basics']['vip_amount'])?$data['basics']['vip_amount']:'' }}" placeholder="请输入用户最低充值金额" maxlength="10">
						</div>
						<div class="form-group col-md-6">
							<label>合伙人分佣比例：</label>
							<input type="text" class="form-control" name="partner_ratio" value="{{ isset($data['basics']['partner_ratio'])?$data['basics']['partner_ratio']:'' }}" placeholder="小于10的数值，最多一位小数" maxlength="3">
						</div>
						<div class="form-group col-md-6">
							<label>客服联系电话：</label>
							<input type="text" class="form-control" name="service_mobile" value="{{ isset($data['basics']['service_mobile'])?$data['basics']['service_mobile']:'' }}" placeholder="请输入客服联系电话" maxlength="20">
						</div>
						<div class="form-group col-md-6">
							<label >实名认证：</label>
							<select class="form-control" id="certification">
								<option value="2" @if(isset($data['basics']['certification']) && $data['basics']['certification']==2)selected @endif>关闭</option>
								<option value="1" @if(isset($data['basics']['certification']) && $data['basics']['certification']==1)selected @endif>开启</option>
							</select>
						</div>

						<div class="form-group col-md-6">
							<label>微信号码：</label>
							<input type="text" class="form-control" name="wechat" value="{{ isset($data['basics']['wechat'])?$data['basics']['wechat']:'' }}" placeholder="请输入微信号码" maxlength="16">
						</div>
						<div class="form-group col-md-6">
							<label>在线客服URL：</label>
							<input type="text" class="form-control" name="service_url" value="{{ isset($data['basics']['service_url'])?$data['basics']['service_url']:'' }}" placeholder="请输入在线客服URL必须http://或https://开头的" maxlength="100">
						</div>
						<div class="form-group col-md-6">
							<label>在线客服QQ：</label>
							<input type="text" class="form-control" name="service_qq" value="{{ isset($data['basics']['service_qq'])?$data['basics']['service_qq']:'' }}" placeholder="请输入在线客服QQ" maxlength="16">
						</div>
							<div class="form-group col-md-6">
								<label>微信客服二维码：</label>
								<div class="form-group upimg">
									<img src="{{ isset($data['basics']['service_code']) && $data['basics']['service_code']!='' ? $data['basics']['service_code'] : '/images/default.png' }}" id="showImg">
									<span class="btn btn-info" id="look">选择图片</span>
									<span class="btn btn-default" id="remove">移除</span>
									<span class="btn btn-success" id="upload" onclick="uploadImg('optImg','imgpath')">上传</span>
									<span id="newfile"><input type="file" name="optImg" id="optImg" onchange="optchange(this)"></span>
									<input type="hidden" name="service_code" id="imgpath" value="{{ isset($data['basics']['service_code']) && $data['basics']['service_code']!='' ? $data['basics']['service_code'] : '/images/default.png' }}">
								</div>
							</div>
						<div class="form-group col-md-12">
							<button type="button" class="btn btn-info" onclick="dataSubmit()">保 存</button>
							<button type="reset" class="btn btn-default">重 置</button>
						</div>
						</form>
					</div>
					<!--  end-->
				</div>
			</div>
		</div>
	</div>
</section>
</div>
@endsection
@section('foot_js')
<script src="{{ asset('/js/apk.js') }}"></script>
<script src="{{ asset('/js/tools.js') }}"></script>
<script type="text/javascript">
/*
保存操作
*/
function dataSubmit(){
	var typeName='basics';
	var partner_discount = $("input[name='partner_discount']").val();
	var vip_discount = $("input[name='vip_discount']").val();
	var partner_amount = $("input[name='partner_amount']").val();
	var vip_amount = $("input[name='vip_amount']").val();
	var partner_ratio = $("input[name='partner_ratio']").val();
	var service_code = $("input[name='service_code']").val();
	var wechat = $("input[name='wechat']").val();
	var service_mobile = $("input[name='service_mobile']").val();
	var service_url = $("input[name='service_url']").val();
	var service_qq = $("input[name='service_qq']").val();
	var certification=$('#certification option:selected') .val();//选中的值
	var url = "{{URL('admin/config/create/save')}}";
	var data = {typeName:typeName,partner_discount:partner_discount,vip_discount:vip_discount,partner_amount:partner_amount,vip_amount:vip_amount,partner_ratio:partner_ratio,
	service_code:service_code,wechat:wechat,service_mobile:service_mobile,service_url:service_url,service_qq:service_qq,certification:certification};
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
		layer.msg(result.msg,{icon:5});
		return false;
	}else{

		setTimeout('window.location.reload()',1000);
		layer.msg(result.msg,{icon:6});
	}
}

function cs(is_auth) {
	var result;
	switch (is_auth) {
		case 0:
			result = layer.confirm('是否开启身份认证', {
				btn: ['确认开启','再考虑一下'] //按钮
			}, function(){
				sqff();
			});
			break;
		case 1:
			result = layer.confirm('是否取消身份认证', {
				btn: ['我要取消认证','再考虑一下'] //按钮
			}, function(){
				sqff();
			});
			break;
	}
	function sqff () {

		var data = '';
		var url = "<?php echo e(URL('admin/user/trusteeship/ajax')); ?>";
		var result = puppet.myajax('post', url, data, false);
		if (result.code == 1) {
			layer.msg(result.msg,{icon:2});
			return false;
		} else {
			layer.msg('操作成功',{icon:6});
			setTimeout('window.location.reload()', 1000);
		}
	}


}
//上传图片到服务器  经过  apk.js  FileTools.php
function uploadImg(file_id,file_val){
	var url = "{{URL('image/single/upload')}}/code";
	var is_ok=uploadImage(file_id,url,file_val,'','');
	if(is_ok!=false){
		$('#upload').css({"display":"none"});
		layer.msg('上传成功',{icon:1});
	}
}
//预览触发上传控件
$('#look').click(function(){$('#optImg').click();});
//上传控件值发生改变替换图片
function optchange(obj){
	$('#remove,#upload').css({"display":"inline-block"});
	var imgSrc=puppet.getObjectURL(obj);
	// console.log(getObjectURL(this.files[0]));
	$('#showImg').attr('src',imgSrc);
}
//移除图片
$('#remove').click(function(){
	var newimg=$('#imgpath').val();
	var oldimg="{{ isset($data['basics']['service_code'])&&$data['basics']['service_code']!='' ? $data['basics']['service_code'] : '/images/default.png' }}";
	$('#newfile').html('<input type="file" name="optImg" id="optImg" onchange="optchange(this)">');
	$('#remove,#upload').css({"display":"none"});
	$('#imgpath').val(oldimg);
	var url="{{URL('image/delete/file')}}";
	// console.log(url);
	if(newimg&&newimg!='/images/default.png'&&newimg!=oldimg){deleteImg(url,newimg);}
	$('#showImg').attr('src',oldimg);
});
</script>
@endsection